package guowenlong.golf.ui.court;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Window;
import android.widget.ImageButton;
import butterknife.BindView;
import butterknife.ButterKnife;
import guowenlong.golf.R;
import guowenlong.golf.ui.home.TabAdapter;
import java.util.ArrayList;
import java.util.List;

/**
 * des   : 描述
 * author: Administrator
 * email : guowenlong20000@gmail.com
 * time  : 2017年04月11日 下午 4:30.
 */

public class CourtActivity extends FragmentActivity {

  @BindView(R.id.ib_back)
  ImageButton ibBack;
  @BindView(R.id.tl_myteam_details)
  TabLayout tlMyteamDetails;
  @BindView(R.id.vp_myteam_details)
  ViewPager vpMyteamDetails;
  private FragmentPagerAdapter fAdapter;
  private List<Fragment> list_fragment;
  private List<String> list_title;
  private CourtOneFragment mCourtOneFragment;
  private CourtTwoFragment mCourtTwoFragment;
  private CourtThreeFragment mCourtThreeFragment;
  private CourtFourFragment mCourtFourFragment;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_court);
    ButterKnife.bind(this);
    initData();
  }

  private void initData() {
    mCourtOneFragment = new CourtOneFragment();
    mCourtTwoFragment = new CourtTwoFragment();
    mCourtThreeFragment = new CourtThreeFragment();
    mCourtFourFragment = new CourtFourFragment();
//    mMyTeamHistoryFragment = new FragmentTeamHistory();
    list_fragment = new ArrayList<>();
    list_fragment.add(mCourtOneFragment);
    list_fragment.add(mCourtTwoFragment);
    list_fragment.add(mCourtThreeFragment);
    list_fragment.add(mCourtFourFragment);

    list_title = new ArrayList<>();
    list_title.add("球场介绍");
    list_title.add("会员消费");
    list_title.add("球场攻略");
    list_title.add("球场纪录");
    tlMyteamDetails.setTabMode(TabLayout.MODE_FIXED);
    tlMyteamDetails.addTab(tlMyteamDetails.newTab().setText(list_title.get(0)));
    tlMyteamDetails.addTab(tlMyteamDetails.newTab().setText(list_title.get(1)));
    tlMyteamDetails.addTab(tlMyteamDetails.newTab().setText(list_title.get(2)));
    tlMyteamDetails.addTab(tlMyteamDetails.newTab().setText(list_title.get(3)));

    fAdapter = new TabAdapter(getSupportFragmentManager(), list_fragment, list_title);

    vpMyteamDetails.setAdapter(fAdapter);
    tlMyteamDetails.setupWithViewPager(vpMyteamDetails);
  }
}
